package be.ipl.finito.domaine;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.sun.istack.internal.NotNull;

@SuppressWarnings("serial")
@Entity
@Table(schema="FINITO", name="CASES")
public class Case implements Serializable {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="CASES_ID")
	private int id;
	
	@NotNull
	private int numeroCase;
	
	@ManyToOne
	@JoinColumn(name="JETON_ID")
	private Jeton jeton;
	
	public static final Map<Integer, Integer> MAPPING_NUMCASE_VALEUR = new HashMap<Integer, Integer>();
	
	static{
		MAPPING_NUMCASE_VALEUR.put(1, 1);
		
		MAPPING_NUMCASE_VALEUR.put(2, 2);
		
		MAPPING_NUMCASE_VALEUR.put(3, 3);
		MAPPING_NUMCASE_VALEUR.put(4, 3);

		MAPPING_NUMCASE_VALEUR.put(5, 4);
		MAPPING_NUMCASE_VALEUR.put(6, 4);
		
		MAPPING_NUMCASE_VALEUR.put(7, 5);
		MAPPING_NUMCASE_VALEUR.put(8, 5);
		
		MAPPING_NUMCASE_VALEUR.put(9, 6);
		MAPPING_NUMCASE_VALEUR.put(10, 6);
		
		MAPPING_NUMCASE_VALEUR.put(11, 7);
		MAPPING_NUMCASE_VALEUR.put(12, 7);
		
		MAPPING_NUMCASE_VALEUR.put(13, 8);
		MAPPING_NUMCASE_VALEUR.put(14, 8);
		
		MAPPING_NUMCASE_VALEUR.put(15, 9);
		MAPPING_NUMCASE_VALEUR.put(16, 9);
		
		MAPPING_NUMCASE_VALEUR.put(17, 10);
		MAPPING_NUMCASE_VALEUR.put(18, 10);
		
		MAPPING_NUMCASE_VALEUR.put(19, 11);
		MAPPING_NUMCASE_VALEUR.put(20, 11);
		
		MAPPING_NUMCASE_VALEUR.put(21, 12);
		MAPPING_NUMCASE_VALEUR.put(22, 12);
		
		MAPPING_NUMCASE_VALEUR.put(23, 13);
		MAPPING_NUMCASE_VALEUR.put(24, 13);
		
		MAPPING_NUMCASE_VALEUR.put(25, 14);
		MAPPING_NUMCASE_VALEUR.put(26, 14);
		
		MAPPING_NUMCASE_VALEUR.put(27, 15);
		MAPPING_NUMCASE_VALEUR.put(28, 15);
		
		MAPPING_NUMCASE_VALEUR.put(29, 16);
		MAPPING_NUMCASE_VALEUR.put(30, 16);
		
		MAPPING_NUMCASE_VALEUR.put(31, 17);
		MAPPING_NUMCASE_VALEUR.put(32, 17);
		
		MAPPING_NUMCASE_VALEUR.put(33, 18);
		MAPPING_NUMCASE_VALEUR.put(34, 18);

		MAPPING_NUMCASE_VALEUR.put(35, 19);
		
		MAPPING_NUMCASE_VALEUR.put(36, 20);
	}
	
	public Case(){
		
	}	
	
	public Case(Jeton jeton, int numeroCase){
		this.jeton = jeton;
		this.numeroCase= numeroCase;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Jeton getJeton() {
		return jeton;
	}

	public void setJeton(Jeton jeton) {
		this.jeton = jeton;
	}

	public int getNumeroCase() {
		return numeroCase;
	}

	public void setNumeroCase(int numeroCase) {
		this.numeroCase = numeroCase;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Case other = (Case) obj;
		if (id != other.id)
			return false;
		return true;
	}
}